﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Invoke.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.Windows.Input
{
    using System.Windows;

    /// <summary>
    /// Attached properties for invoke behaviors.
    /// </summary>
    public static class Invoke
    {
        /// <summary>
        /// Value used to represent an unset value for the target.
        /// </summary>
        public static readonly object TargetUnsetValue = "Target.UnsetValue";

        /// <summary>
        /// The <see cref="ScopeProperty"/> used to propagate changes to <see cref="TargetProperty"/>.
        /// </summary>
        public static ScopeProperty TargetScopeProperty = ScopeProperty.RegisterAttached("Target", typeof(object), 
            typeof(Invoke), new ScopePropertyMetadata(TargetUnsetValue));

        /// <summary>
        /// The target attacged <see cref="DependencyProperty"/>.
        /// </summary>
        public static DependencyProperty TargetProperty = TargetScopeProperty.Property;

        /// <summary>
        /// Gets the target for the specified <paramref name="obj"/>.
        /// </summary>
        /// <param name="obj">The obj whost target value should be get.</param>
        /// <returns>The target value.</returns>
        public static object GetTarget(DependencyObject obj)
        {
            return obj.GetValue(TargetProperty);
        }

        /// <summary>
        /// Sets the target for the specified <paramref name="obj"/>.
        /// </summary>
        /// <param name="obj">The obj whost target value should be set.</param>
        /// <param name="value">The value.</param>
        public static void SetTarget(DependencyObject obj, object value)
        {
            obj.SetValue(TargetProperty, value);
        }
    }
}